package com.medic.web.controller;

import java.sql.Timestamp;
import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;


import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.medic.entity.Group;
import com.medic.service.impl.GroupServiceImpl;

@Controller
@RequestMapping("web/wizard")
public class WizardController {
	
	
	
	@Resource
	private GroupServiceImpl groupService;
	
	@ResponseBody 
	@RequestMapping("action/create")
	public Object createGroup(Group group){
		Map<String,Object> object = new HashMap<String,Object>();
		try{
		
			group.setCtime(new Timestamp(System.currentTimeMillis()).toString());
			
			
			groupService.createGroup(group);
			
		}catch(Exception ee){
			ee.printStackTrace( );
			object.put("status", "error");
		}
		
		
		return object;
	}
	
	
	
	@RequestMapping("index")
	public String index(@RequestParam("f")String url ,Model model){

		model.addAttribute("f", url);
		
		return  "/web/WIZARD";
	}
	
}
